package com.example.lifecycledemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {

    private LocationListener mListener;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mListener = new LocationListener(this, new LocationListener.onLocationChangeListener() {
            @Override
            public void onChange(double latitude, double longitude) {
                Log.i("aaaa", "onChange: "+latitude+"=="+longitude);
            }
        });
        getLifecycle().addObserver(mListener);


    }

    @Override
    protected void onStop() {
        getLifecycle().removeObserver(mListener);
        super.onStop();
    }
}